package com.le.tester.leetcode;

import java.util.*;

/**
 * createTime：2022/11/23 14:28
 * description：最好的手牌类型
 */
public class BestHand {
    public String getBestHand(int[] ranks, char[] suits) {
        Map<Integer, Integer> ranksMap = new HashMap<>();
        Set<Character> setList = new HashSet<>();
        try {

            for (char item : suits) {
                setList.add(item);
            }
            for (int item : ranks) {
                Integer mapVal = ranksMap.get(item);
                if (Objects.isNull(mapVal)) {
                    ranksMap.put(item, 1);
                } else {
                    ranksMap.put(item, mapVal + 1);
                }
            }

            Integer max = ranksMap.values().stream().max(Integer::compareTo).get();
            if (max > 2) {
                return "Three of a Kind";
            }

            if (max > 1) {
                return "Pair";
            }

            if (ranksMap.size() == 5 && setList.size() == 1) {
                return "Flush";
            }

            return "High Card";
        } finally {
            ranksMap.clear();
            setList.clear();
        }
    }

    public static void main(String[] args) {
        int[] i = new int[]{12, 12, 12, 9, 9};
        char[] c = new char[]{'b', 'd', 'a', 'c', 'b'};

        System.out.println(new BestHand().getBestHand(i, c));
    }
}
